# -*- mode: python ; coding: utf-8 -*-
import pathlib
import shutil

version = [n for n in pathlib.Path('vars.py').read_text(encoding='utf-8').splitlines() if n.startswith('VERSION')][0].split('=')[-1].strip().strip("'")
dirname = '战场双马尾[纪念版]-v' + version


a = Analysis(
    ['GameStart.py'],
    pathex=[],
    binaries=[],
    datas=[
        ('.\config.yaml', '.'),
        ('.\说明.md', '.'),
        ('.\Data\SenjoTwintail.db', '.\Data'),
        ('.\Data\saveDataAll.yaml', '.\Data'),
        (r'.\Data\assets', r'.\Data\assets')
    ],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    [],
    icon=r'.\Data\assets\icon\icon.ico',
    exclude_binaries=True,
    name='战场双马尾',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
coll = COLLECT(
    exe,
    a.binaries,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name=dirname,
)


# 后置处理
if pathlib.Path('build').exists():
    shutil.rmtree('build')
saveData_yaml = pathlib.Path('dist') / dirname / '_internal' / 'Data' / 'saveDataAll.yaml'

if saveData_yaml.exists():
    saveData_yaml.rename(saveData_yaml.parent / saveData_yaml.name.replace('All', ''))

readme_md = pathlib.Path('dist') / dirname / '_internal' / '说明.md'
if readme_md.exists():
    readme_md.rename(readme_md.parents[1] / readme_md.name)


